package com.slt.android.osmessageandsecurity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewStub;
import android.widget.TextView;

/**
 *
 * ViewStub 、用来实现View的延迟加载
 * Created by dp on 2018/1/31.
 */

public class ViewStubActivity extends Activity {

    ViewStub itemView;
    TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view);

        tv = (TextView) findViewById(R.id.tv);
        itemView = (ViewStub) findViewById(R.id.viewStub);

        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //这2个方法都可以重新显示这个view，区别是inflate()方法可以得到view的引用。再去item的layout中操作。
//                itemView.setVisibility(View.VISIBLE);
//                itemView.inflate();
            }
        });

    }
}
